package com.qf.fmall01.controller;

import com.qf.fmall01.service.CategoryService;
import com.qf.fmall01.service.IndexImgService;
import com.qf.fmall01.service.ProductService;
import com.qf.fmall01.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("index")
@CrossOrigin
public class IndexController {

    @Autowired
    private IndexImgService indexImgService;

    @Autowired
    private CategoryService categoryService;

    @Autowired
    private ProductService productService;

    @GetMapping("/indeximg")
    @ResponseBody
    public ResultVO listIndexImgs(){
        return indexImgService.listIndexImgs();
    }

    @GetMapping("/category-list")
    @ResponseBody
    public ResultVO listCatetory(){
        return categoryService.listCategories();
    }

    @GetMapping("/list-recommends")
    @ResponseBody
    public ResultVO listrecommends(){ return productService.listrecommends(); }

    @GetMapping("/category-recommends")
    @ResponseBody
    public ResultVO categoryRecommends(){
        return productService.categoryRecommends();
    }
}
